package andrei.mower2.business;

import andrei.mower2.business.Mower.Command;
import andrei.mower2.business.Mower.Direction;

public final class MowerVector {

	public final Position position;
	public final Direction direction;
	private final Compass compass;
	
	public MowerVector(Position position, Direction direction) {
		this.position = position;
		this.direction = direction;
		this.compass = Compass.getInstance();
	}
	
	MowerVector advance() {
		Position newPosition = new Position(position.x + direction.xAdvancement, 
				position.y + direction.yAdvancement);
		return new MowerVector(newPosition, direction);
	}
	
	MowerVector rotate(Command command) {
		Direction newDirection = compass.rotateCW(direction, command);
		return new MowerVector(position, newDirection);
	}
}
